package com.slink.fxfk.framework.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 环境变量类
 * 
 * @author 新
 * 
 */
public class Env
{
	private static final Log logger = LogFactory.getLog(Env.class);
	private Properties props;

	public Env()
	{
		try
		{
			reInit();
		} catch (Exception e)
		{
			if (logger.isErrorEnabled())
			{
				logger.error(e.getMessage(), e);
			}

			System.exit(1);
		}
	}

	public void reInit() throws FileNotFoundException, IOException
	{
		Properties prop = new Properties(System.getProperties());
		prop=new Properties(prop);
		prop.load(this.getClass().getResourceAsStream("/env.properties"));
		this.props = prop;
	}

	public String getProp(String key)
	{
		return this.props.getProperty(key);
	}
	
    public String getFormatProp(String key,Object... args)
    {
        return MessageFormat.format(this.props.getProperty(key), args);
    }
}
